module.exports = {
	data() {
		return {
			/* 刷新加载文本 */
			refreshLoadConfig: {
				pullToRefresh: {
					contentdown: {
						caption: '下拉刷新',
					},
					contentover: {
						caption: '释放刷新', //"释放刷新",
					},
					contentrefresh: {
						caption: '',
					}
				},
			},
			loadMoreEnable: '',
			loadling: false,
			emptyShow: false,
			pageSize: 10,
			pageNum: 1,
			loadText: {
				loading: '加载中...',
				over: '没有更多了',
				erro: '加载失败,点击重试',
			},
		}
	},
	computed: {
		loadMoreText() {
			return this.loadText[this.loadMoreEnable];
		}
	},
	methods: {
		/* 设置原生刷新文本 */
		// initPullStyle() {
		// 	let pages = getCurrentPages();
		// 	let page = pages[pages.length - 1];
		// 	let currentWebview = page.$getAppWebview();
		// 	currentWebview.setStyle(this.refreshLoadConfig.pullToRefresh);

		// },
		/* 刷新状态处理 */
		refreshHandler(resultCount, total, pageSize = 10) {
			this.loadling = true;
			if (total <= pageSize) {
				//不满一页 不能加载更多
				this.loadMoreEnable = 'over';
			} else {
				//可以加载更多
				this.loadMoreEnable = 'loading';
			}
			// uni.stopPullDownRefresh();
		},
		/* 加载更多处理 */
		loadMoreHandler(listCount, resultCount, total, pageSize = 10) {
			if (resultCount >= pageSize) {
				if (listCount < total) {
					//当前展示数量小于总数 可以加载更多
					this.loadMoreEnable = 'loading';
				} else {
					this.loadMoreEnable = 'over';
				}
			} else {
				//不满一页 不能加载更多
				this.loadMoreEnable = 'over';
			}
			// uni.stopPullDownRefresh();
		},
		emptyHandler(listCount) {
			if (listCount <= 0) {
				this.emptyShow = true;
				this.loadling = false;
			}
		}
	}
}
